home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / intrvews / xgrab.lha / xgrab / ui / OGC / gctest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-06  |  699 b   |  38 lines

  1. /**
  2.    GRAB Graph Layout and Browser System
  3.  
  4.    Copyright (c) 1989, Tera Computer Company
  5.  **/
  6.  
  7. #include <stdio.h> 
  8.  
  9. const int sz = 200 ;
  10. extern "C" { long random() ; }
  11. extern "C" { void gc_init() ; }
  12.  
  13. int main() {
  14.  
  15.       gc_init() ;
  16.       char **cp = new char * [sz] ;
  17.       int  *szs = new int [sz] ;
  18.       int total = 0, cur = 0 ;
  19.       int i, inuse = 0 ;
  20.       for(i =0; i < sz; i++) szs[i] = 0 ;
  21.  
  22.       printf("Go: ") ;
  23.       for(;;) {
  24.         int i = random() % sz ;
  25.         int j = random() % sz ;
  26.         cp[i] = new char[j] ;
  27.         cur += j ;
  28.         inuse += j - szs[i] ;
  29.         szs[i] = j ;
  30.         if(cur > 1000) {
  31.           total += cur ;
  32.           cur = 0 ;
  33.           printf("%d (%d) \n",total,inuse) ;
  34.         }
  35.       }
  36.  
  37. }
  38.